****************************************************************************************************************************************************
***Analyses for: "Greed, Envy, and Admiration: The Distinct Nature of Public Opinion about Redistribution from the Rich" ***************************
****************************************************************************************************************************************************
****************************************************************************************************************************************************
****************************************************************************************************************************************************

*set working directory 
*to produce tables, download and install esttab: ssc install estout 
*to produce figures, download and install coefplot: ssc install coefplot

**********************************************************************************
****Testing H1 using Sample 1, Sample 2 and Sample 4******************************
**********************************************************************************

use "prepared data 1", clear

reg taxrich effort_rich proso_rich Age Gender Income Education i.party
test effort_rich=proso_rich 
eststo Rich1

use "prepared data 2", clear

reg taxrich effort_rich proso_rich Age Gender Income Education Race i.party
test effort_rich=proso_rich 
eststo Rich2

use "prepared data 4", clear

reg taxrich effort_rich proso_rich Age Gender Income Education Race i.party
test effort_rich=proso_rich 
eststo Rich4

*Table 3

esttab Rich1 Rich2 Rich4, b(%05.3f) se(%5.3f), using tab3.rtf, replace onecell star (+ 0.10 * 0.05 ** 0.01 *** 0.001) wide constant ar2 

***********************************************************************************
****Testing contrasts with the poor using Sample 1, Sample 2 and Sample 4**********
***********************************************************************************

use "prepared data 1", clear

reg welfare effort_poor proso_poor Age Gender Income Education i.party
test effort_poor=proso_poor 
eststo Poor1

use "prepared data 2", clear

reg welfare effort_poor proso_poor Age Gender Income Education Race i.party
test effort_poor=proso_poor 
eststo Poor2

use "prepared data 4", clear

reg welfare effort_poor proso_poor Age Gender Income Education Race i.party
test effort_poor=proso_poor 
eststo Poor4

*Table 4

esttab Poor1 Poor2 Poor4, b(%05.3f) se(%5.3f), using tab4.rtf, replace onecell star (+ 0.10 * 0.05 ** 0.01 *** 0.001) wide constant ar2

*Figure 1

coefplot (Rich1), ylabel(0.0(0.1)0.6) level(95) keep(effort_rich proso_rich) yline(0, lcolor(black)) ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Oppose taxes on the rich. (Sample 1)", size(medlarge)) ///
name(fig1samp1rich, replace)

coefplot (Poor1), ylabel(0.0(0.1)0.6) level(95) keep(effort_poor proso_poor) yline(0, lcolor(black)) ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Support social welfare. (Sample 1)", size(medlarge)) ///
name(fig1samp1poor, replace)

coefplot (Rich2), ylabel(0.0(0.1)0.6) level(95) keep(effort_rich proso_rich) yline(0, lcolor(black)) ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Oppose taxes on the rich. (Sample 2)", size(mmedlarge)) ///
name(fig1samp2rich, replace)

coefplot (Poor2), ylabel(0.0(0.1)0.6) level(95) keep(effort_poor proso_poor) yline(0, lcolor(black)) ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Support social welfare. (Sample 2)", size(medlarge)) ///
name(fig1samp2poor, replace)

coefplot (Rich4), ylabel(0.0(0.1)0.6) level(95) keep(effort_rich proso_rich) yline(0, lcolor(black)) ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Oppose taxes on the rich. (Sample 4)", size(medlarge)) ///
name(fig1samp4rich, replace)

coefplot (Poor4), ylabel(0.0(0.1)0.6) level(95) keep(effort_poor proso_poor) yline(0, lcolor(black)) ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Support social welfare. (Sample 4)", size(medlarge)) ///
name(fig1samp4poor, replace)

graph combine fig1samp1rich fig1samp1poor fig1samp2rich fig1samp2poor fig1samp4rich fig1samp4poor, graphregion(fcolor(white)) cols(2) rows(3) ysize(1.5) xsize(1) iscale(0.6)

graph export "Figure1.png", as(png) replace

**********************************************************************************
****Testing H1 using Sample 3 ****************************************************
**********************************************************************************

use "prepared data 3", clear

reg taxrich effort proso
test effort=proso
eststo taxrich

reg demand effort proso
test effort=proso
eststo demand

reg richinequality effort proso
test effort=proso
eststo richinequality

*Table 5

esttab taxrich demand richinequality, b(%05.3f) se(%5.3f), using tab5.rtf, replace onecell star (+ 0.10 * 0.05 ** 0.01 *** 0.001) wide constant ar2

**********************************************************************************
****Testing contrasts with the poor using Sample 3 *******************************
**********************************************************************************

use "prepared data 3", clear

reg welfare effort proso
test effort=proso
eststo welfare

reg help effort proso
test effort=proso
eststo help

reg poorinequality effort proso 
test effort=proso
eststo poorinequality

*Table 6

esttab welfare help poorinequality, b(%05.3f) se(%5.3f), using tab6.rtf, replace onecell star (+ 0.10 * 0.05 ** 0.01 *** 0.001) wide constant ar2

**********************************************************************************
****Testing H2 and H3 using Sample 2, Sample 3 and Sample 4***********************
**********************************************************************************

use "prepared data 2", clear

reg taxrich envy_r admi_r comp_r Age Gender Income Education i.party Race
eststo Rich2

use "prepared data 3.dta", clear

reg taxrich envy admi comp Age Gender Income Education i.party
eststo Rich3

use "prepared data 4", clear

reg taxrich envy_r admi_r comp_r Age Gender Income Education i.party Race
eststo Rich4

*Table 7

esttab Rich2 Rich3 Rich4, b(%05.3f) se(%5.3f), using tab7.rtf, replace onecell star (+ 0.10 * 0.05 ** 0.01 *** 0.001) wide constant ar2

**********************************************************************************
****Testing H2 and H3 using Sample 2, Sample 3 and Sample 4***********************
**********************************************************************************

use "prepared data 2", clear

reg welfare envy_p admi_p comp_p Age Gender Income Education i.party Race
eststo Poor2

use "prepared data 3", clear

reg welfare envy admi comp Age Gender Income Education i.party
eststo Poor3

use "prepared data 4", clear

reg welfare envy_p admi_p comp_p Age Gender Income Education i.party Race
eststo Poor4

*Table 8

esttab Poor2 Poor3 Poor4, b(%05.3f) se(%5.3f), using tab8.rtf, replace onecell star (+ 0.10 * 0.05 ** 0.01 *** 0.001) wide constant ar2

*Figure 3

coefplot (Rich2), ylabel(-0.60(0.20)0.70) level(95) yline(0) yline(0, lcolor(black)) keep(envy_r admi_r comp_r) ///
coeflabels(envy_r="Envy" admi_r="Admiration" comp_r="Compassion") ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Oppose taxes on the rich. (Sample 2)", size(medlarge)) ///
name(fig3samp2rich, replace)

coefplot (Rich3), ylabel(-0.60(0.20)0.70) level(95) yline(0, lcolor(black)) keep(envy admi comp) ///
coeflabels(envy="Envy" admi="Admiration" comp="Compassion") ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Oppose taxes on the rich. (Sample 3)", size(mmedlarge)) ///
name(fig3samp3rich, replace)

coefplot (Rich4), ylabel(-0.60(0.20)0.70) level(95) yline(0, lcolor(black)) keep(envy_r admi_r comp_r) ///
coeflabels(envy_r="Envy" admi_r="Admiration" comp_r="Compassion") ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Oppose taxes on the rich. (Sample 4)", size(mmedlarge)) ///
name(fig3samp4rich, replace)

coefplot (Poor2), ylabel(-0.60(0.20)0.70) level(95) yline(0, lcolor(black)) keep(envy_p admi_p comp_p) ///
coeflabels(envy_p="Envy" admi_p="Admiration" comp_p="Compassion") ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Support social welfare. (Sample 2)", size(medlarge)) ///
name(fig3samp2poor, replace)

coefplot (Poor3), ylabel(-0.60(0.20)0.70) level(95) yline(0, lcolor(black)) keep(envy admi comp) ///
coeflabels(envy="Envy" admi="Admiration" comp="Compassion") ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Support social welfare. (Sample 3)", size(medlarge)) ///
name(fig3samp3poor, replace)

coefplot (Poor4), ylabel(-0.60(0.20)0.70) level(95) yline(0, lcolor(black)) keep(envy_p admi_p comp_p) ///
coeflabels(envy_p="Envy" admi_p="Admiration" comp_p="Compassion") ///
vertical graphregion(fcolor(white)) mcolor(black) ciopts(lcolor(black)) title("Support social welfare. (Sample 4)", size(medlarge)) ///
name(fig3samp4poor, replace)

graph combine fig3samp2rich fig3samp2poor fig3samp3rich fig3samp3poor fig3samp4rich fig3samp4poor, graphregion(fcolor(white)) cols(2) rows(3) ysize(1.5) xsize(1) iscale(0.6) 

graph export "Figure3.png", as(png) replace
